package com.srmt.spring.service;

import com.srmt.document.api.ContentReader;
import com.srmt.document.api.ContentWriter;
import com.srmt.document.api.DocumentManager;
import com.srmt.document.api.DocumentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * Spring 增强的 DocumentService 包装器
 * 提供生命周期管理和额外的Spring特性
 * 
 * @author SRMT Development Team
 * @since 2.0.0
 */
public class SpringDocumentServiceWrapper implements DocumentService, InitializingBean, DisposableBean {
    
    private static final Logger logger = LoggerFactory.getLogger(SpringDocumentServiceWrapper.class);
    
    private final DocumentService delegate;
    
    public SpringDocumentServiceWrapper(DocumentService delegate) {
        this.delegate = delegate;
    }
    
    @Override
    public DocumentManager getDocumentManager() {
        return delegate.getDocumentManager();
    }
    
    @Override
    public ContentWriter getContentWriter() {
        return delegate.getContentWriter();
    }
    
    @Override
    public ContentReader getContentReader() {
        return delegate.getContentReader();
    }
    
    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("文档服务 initialized successfully");
        // 可以在这里添加初始化逻辑，如预热缓存等
    }
    
    @Override
    public void destroy() throws Exception {
        logger.info("文档服务 is being destroyed");
        // 可以在这里添加清理逻辑，如关闭连接、清理缓存等
    }
    
    /**
     * 获取原始的 DocumentService 实例
     * 
     * @return 原始服务实例
     */
    public DocumentService getDelegate() {
        return delegate;
    }
}